package com.p900.website.service.impl;

import com.p900.commons.domain.Platform;
import com.p900.website.repository.PlatformRepository;
import com.p900.website.service.PlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.validation.constraints.NotNull;

/**
 * Created by lenovo on 2015/5/2.
 */
@Service
public class PlatformServiceImpl implements PlatformService {

    @Autowired
    private PlatformRepository platformRepository;

    @Override
    public Platform findPlatform(Long id) {
        Assert.notNull(id, "platfrom.notnull");
        return platformRepository.findOne(id);
    }

    @Override
    public Platform save(Platform platform) {
        return platformRepository.save(platform);
    }

    @Override
    public Page<Platform> findAll(Pageable pageable){
        return platformRepository.findAll(pageable);
    }

    @Override
    public void delete(@NotNull(message = "id is null") Long id) {
        platformRepository.delete(id);
    }
}
